package com.goodcol.plugin.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.intellij.database.psi.DbTable;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 从database插件的表生成时，构造的TableInfo对象
 *
 * @author 单红宇
 * @date 2024/2/1 10:23
 */
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class DbTableInfo extends TableInfo {

    /**
     * 数据库表原始对象
     */
    @JsonIgnore
    private DbTable obj;

    @Override
    public String getTableName() {
        if(obj == null) {
            return "";
        }
        return obj.getName();
    }

    @Override
    public DbTable getObj() {
        return this.obj;
    }

}
